home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Borland Plateform / Turbo Pascal V7.0 / DOCDEMO.ZIP / IMPORT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-10-30  |  2.8 KB  |  128 lines

  1. {************************************************}
  2. {                                                }
  3. {   Turbo Vision 2.0 Demo                        }
  4. {   Copyright (c) 1992 by Borland International  }
  5. {                                                }
  6. {************************************************}
  7.  
  8. program Import;
  9.  
  10. uses Objects, TutTypes, Dos;
  11.  
  12. var
  13.   InFile: Text;
  14.   OutFile: TBufStream;
  15.   C: TCollection;
  16.   S: String;
  17.   Supplier: PSupplierObj;
  18.   StockItem: PStockItemObj;
  19.   Order: POrderObj;
  20.   w: Word;
  21.  
  22. begin
  23.  
  24.   if ParamCount <> 1 then
  25.   begin
  26.     writeln('Enter "1", "2", or "3"');
  27.     Halt(1);
  28.   end;
  29.  
  30.   RegisterGlobals;
  31.   RegisterType(RCollection);
  32.  
  33.  
  34.   if ParamStr(1) = '1' then
  35.   begin
  36.  
  37.     { Convert SUPPLIER.TXT to SUPPLIER.DAT }
  38.  
  39.     C.Init(10, 1);
  40.     OutFile.Init('SUPPLIER.DAT', stCreate, 1024);
  41.     Assign(InFile, 'Supplier.txt');
  42.     Reset(InFile);
  43.  
  44.     while not eof(InFile) do
  45.     begin
  46.       New(Supplier, Init);
  47.       with Supplier^.TransferRecord do
  48.       begin
  49.         Readln(InFile, S); AccountNo := S;
  50.         ReadLn(InFile, S); CompanyName := S;
  51.         Readln(infile, s); Address1 := S;
  52.         Readln(infile, s); Address2 := S;
  53.         Readln(infile, s); Address3 := S;
  54.         Readln(infile, s); Phone := S;
  55.       end;
  56.       C.Insert(Supplier);
  57.     end;
  58.  
  59.     OutFile.Put(@C);
  60.  
  61.     Close(InFile);
  62.     OutFile.Done;
  63.     C.Done;
  64.   end;
  65.  
  66.   if ParamStr(1) = '2' then
  67.   begin
  68.     { Convert ITEMS.TXT to ITEMS.DAT }
  69.  
  70.     C.Init(10, 1);
  71.     OutFile.Init('ITEMS.DAT', stCreate, 1024);
  72.     Assign(InFile, 'Items.txt');
  73.     Reset(InFile);
  74.  
  75.     while not eof(InFile) do
  76.     begin
  77.       New(StockItem, Init);
  78.       with StockItem^.TransferRecord do
  79.       begin
  80.         Readln(InFile, S); StockNo := S;
  81.         Readln(InFile, S); Description := S;
  82.         Readln(InFile, S); QtyOnHand := S;
  83.         Readln(InFile, S); UnitCost := S;
  84.         Readln(InFile, S); Supplier := S;
  85.       end;
  86.       C.Insert(StockItem);
  87.     end;
  88.  
  89.     OutFile.Put(@C);
  90.  
  91.     Close(InFile);
  92.     OutFile.Done;
  93.     C.Done;
  94.   end;
  95.  
  96.   if ParamStr(1) = '3' then
  97.   begin
  98.     { Convert ORDERS.TXT to ORDERS.DAT }
  99.  
  100.     C.Init(10, 1);
  101.     OutFile.Init('ORDERS.DAT', stCreate, 1024);
  102.     Assign(InFile, 'Orders.txt');
  103.     Reset(InFile);
  104.  
  105.     while not eof(InFile) do
  106.     begin
  107.       New(Order, Init);
  108.       with Order^.TransferRecord do
  109.       begin
  110.         Readln(InFile, S); OrderNum := S;
  111.         Readln(InFile, S); StockNum := S;
  112.         Readln(InFile, S); OrderDate := S;
  113.         Readln(InFile, S); Quantity := S;
  114.         Readln(InFile, w); Payment := W;
  115.         Readln(InFile, w); Received := W;
  116.         Readln(InFile, w); MemoLen := W;
  117.       end;
  118.       C.Insert(Order);
  119.     end;
  120.  
  121.     OutFile.Put(@C);
  122.  
  123.     Close(InFile);
  124.     OutFile.Done;
  125.     C.Done;
  126.   end;
  127.  
  128. end.